/*年轻人，只管向前看，不要管自暴自弃者的话*/
package com.composetest.page.product.detail

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.viewmodel.compose.viewModel
import com.composetest.ui.theme.ComposeTestTheme


/**
 * create by itz on 2024-10-16 16:32
 * desc :
 **/
@Composable
fun ProductDetailRoute(toBack: () -> Unit) {

    val viewModel: ProductDetailViewModel = viewModel()
    val productId by viewModel.productId.collectAsState()
    ProductDetailScreen(toBack = toBack, productId = productId)
}

@Composable
fun ProductDetailScreen(toBack: () -> Unit = {}, productId: String = "") {

    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.White)
    ) {
        Text(text = "商品详情id = $productId")
    }

}

@Preview
@Composable
fun ProductDetailScreenPreview() {
    ComposeTestTheme {
        ProductDetailScreen()
    }
}